import { get } from 'lodash-es'

export class User {
  id?: string
  login_name?: string
  password_new?: string
  password_changed?: string | Date
  user_type?: string
  mobile?: string
  email?: string
  xlast?: string
  xfirst?: string
  xfull_name?: string
  last?: string
  first?: string
  position?: string
  gender_id?: string
  last_login?: string | Date
  last_hotel_id?: string
  error_times?: number
  lock_date?: string | Date
  status?: string
  reference?: string
  created_id?: string
  updated_id?: string
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: User) {
    this.init(data)
  }
}

User.prototype.init = function init(data?: User) {
  this.id = get(data, 'id')
  this.login_name = get(data, 'login_name')
  this.password_new = get(data, 'password_new')
  this.password_changed = get(data, 'password_changed')
  this.user_type = get(data, 'user_type', 'Customer')
  this.mobile = get(data, 'mobile')
  this.email = get(data, 'email')
  this.xlast = get(data, 'xlast')
  this.xfirst = get(data, 'xfirst')
  this.xfull_name = get(data, 'xfull_name')
  this.last = get(data, 'last')
  this.first = get(data, 'first')
  this.position = get(data, 'position')
  this.gender_id = get(data, 'gender_id')
  this.last_login = get(data, 'last_login')
  this.last_hotel_id = get(data, 'last_hotel_id')
  this.error_times = get(data, 'error_times', 0)
  this.lock_date = get(data, 'lock_date')
  this.status = get(data, 'status', 'Active')
  this.reference = get(data, 'reference')
  this.created_id = get(data, 'created_id')
  this.updated_id = get(data, 'updated_id')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_id')
  this.version = get(data, 'version')
}
